package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 护工与护工组表
 */
@Entity
@Table(name = "tnb_employee_nursingGroup")
@JsonApiResource(type = "employeenursinggroup")
public class EmployeeNursingGroup extends BaseEntity { 
	private Employee employee;// 护工
	private NurseGroup group;// 护理组
	private String remark;//备注


	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "employee_id",foreignKey = @ForeignKey(name = "null"))
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically 
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "group_id",foreignKey = @ForeignKey(name = "null"))
	public NurseGroup getGroup() {
		return group;
	}

	public void setGroup(NurseGroup group) {
		this.group = group;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
}